home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / tests / host / RCS / host.c,v < prev   
Encoding:
Text File  |  1988-12-15  |  5.1 KB  |  219 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     88.12.15.09.27.17;  author ouster;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     88.06.30.11.06.17;  author ouster;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Change argument to Host_ByNetAddr from Address to char *.
  27. @
  28. text
  29. @/* 
  30.  * host.c --
  31.  *
  32.  *    This file contains a program that exercises the Host_
  33.  *    library procedures.  Invoke it with no parameters;  it
  34.  *    will print messages on stderr for any problems it detects
  35.  *    with the string procedures.
  36.  *
  37.  * Copyright 1988 Regents of the University of California
  38.  * Permission to use, copy, modify, and distribute this
  39.  * software and its documentation for any purpose and without
  40.  * fee is hereby granted, provided that the above copyright
  41.  * notice appear in all copies.  The University of California
  42.  * makes no representations about the suitability of this
  43.  * software for any purpose.  It is provided "as is" without
  44.  * express or implied warranty.
  45.  */
  46.  
  47. #ifndef lint
  48. static char rcsid[] = "$Header: host.c,v 1.1 88/06/30 11:06:17 ouster Exp $ SPRITE (Berkeley)";
  49. #endif not lint
  50.  
  51. #include <stdio.h>
  52. #include <host.h>
  53. #include <sys/types.h>
  54. #include <netinet/in.h>
  55. #include <arpa/inet.h>
  56.  
  57. #define error(string) \
  58.     fprintf(stderr, string); \
  59.     exit(1);
  60.  
  61. main()
  62. {
  63.     Host_Entry *entryPtr;
  64.     struct in_addr addr;
  65.     static unsigned char etherAddr[6] = {8, 0, 0x20, 1, 0x5c, 0xce};
  66.     int i;
  67.  
  68.     if (Host_SetFile("gorp") != -1) {
  69.     error("host error 1\n");
  70.     }
  71.     if (Host_SetFile("file1") != 0) {
  72.     error("host error 2\n");
  73.     }
  74.     entryPtr = Host_Next();
  75.     if (entryPtr == NULL) {
  76.     error("host error 3\n");
  77.     }
  78.     if (strcmp(entryPtr->name, "lust.Berkeley.EDU") != 0) {
  79.     error("host error 4\n");
  80.     }
  81.     if (strcmp(entryPtr->aliases[0], "lust") != 0) {
  82.     error("host error 5\n");
  83.     }
  84.     if (entryPtr->aliases[1] != 0) {
  85.     error("host error 6\n");
  86.     }
  87.     if (entryPtr->id != 1) {
  88.     error("host error 7\n");
  89.     }
  90.     if (entryPtr->netType != HOST_ETHER) {
  91.     error("host error 8\n");
  92.     }
  93.     if ((entryPtr->netAddr.etherAddr[0] != 8)
  94.         || (entryPtr->netAddr.etherAddr[1] != 0)
  95.         || (entryPtr->netAddr.etherAddr[2] != 0x20)
  96.         || (entryPtr->netAddr.etherAddr[3] != 1)
  97.         || (entryPtr->netAddr.etherAddr[4] != 2)
  98.         || (entryPtr->netAddr.etherAddr[5] != 0xc6)) {
  99.     error("host error 9\n");
  100.     }
  101.     if (entryPtr->inetAddr.s_addr != inet_addr("128.32.150.11")) {
  102.     error("host error 10\n");
  103.     }
  104.     Host_End();
  105.     entryPtr = Host_ByID(5);
  106.     if (entryPtr == NULL) {
  107.     error("host error 11\n");
  108.     }
  109.     if (strcmp(entryPtr->name, "basil.Berkeley.EDU") != 0) {
  110.     error("host error 12\n");
  111.     }
  112.     entryPtr = Host_ByID(108);
  113.     if (entryPtr != NULL) {
  114.     error("host error 13\n");
  115.     }
  116.     addr.s_addr = inet_addr("128.32.150.8");
  117.     entryPtr = Host_ByInetAddr(addr);
  118.     if (entryPtr == NULL) {
  119.     error("host error 14\n");
  120.     }
  121.     if (strcmp(entryPtr->name, "paprika.Berkeley.EDU") != 0) {
  122.     error("host error 15\n");
  123.     }
  124.     entryPtr = Host_ByInetAddr(46);
  125.     if (entryPtr != NULL) {
  126.     error("host error 16\n");
  127.     }
  128.     entryPtr = Host_ByName("mace.Berkeley.EDU");
  129.     if (entryPtr == NULL) {
  130.     error("host error 17\n");
  131.     }
  132.     if (entryPtr->id != 27) {
  133.     error("host error 18\n");
  134.     }
  135.     entryPtr = Host_ByName("oregano");
  136.     if (entryPtr == NULL) {
  137.     error("host error 19\n");
  138.     }
  139.     if (entryPtr->id != 38) {
  140.     error("host error 20\n");
  141.     }
  142.     entryPtr = Host_ByName("foobar");
  143.     if (entryPtr != NULL) {
  144.     error("host error 21\n");
  145.     }
  146.     entryPtr = Host_ByNetAddr(HOST_ETHER, (char *) etherAddr);
  147.     if (entryPtr == NULL) {
  148.     error("host error 22\n");
  149.     }
  150.     if (strcmp(entryPtr->name, "mint.Berkeley.EDU") != 0) {
  151.     error("host error 23\n");
  152.     }
  153.     etherAddr[0] = 0xff;
  154.     entryPtr = Host_ByNetAddr(HOST_ETHER, (char *) etherAddr);
  155.     if (entryPtr != NULL) {
  156.     error("host error 24\n");
  157.     }
  158.     if (Host_Start() != 0) {
  159.     error("host error 25\n");
  160.     }
  161.     for (i = 0; Host_Next() != NULL; i++) {
  162.     /* Null body. */
  163.     }
  164.     if (i != 33) {
  165.     error("host error 26\n");
  166.     }
  167.     Host_SetFile("file2");
  168.     if (Host_Next() != NULL) {
  169.     error("host error 27\n");
  170.     }
  171.     Host_SetFile("file3");
  172.     if (Host_Next() != NULL) {
  173.     error("host error 28\n");
  174.     }
  175.     Host_SetFile("file4");
  176.     if (Host_Next() != NULL) {
  177.     error("host error 29\n");
  178.     }
  179.     Host_SetFile("file5");
  180.     if (Host_Next() != NULL) {
  181.     error("host error 30\n");
  182.     }
  183.     Host_SetFile("file6");
  184.     if (Host_Next() != NULL) {
  185.     error("host error 31\n");
  186.     }
  187.     Host_SetFile("file7");
  188.     if (Host_Next() != NULL) {
  189.     error("host error 31\n");
  190.     }
  191.     Host_SetFile("file8");
  192.     entryPtr = Host_ByName("10");
  193.     if (entryPtr == NULL) {
  194.     error("host error 32\n");
  195.     }
  196.     entryPtr = Host_ByName("savory");
  197.     if (entryPtr == NULL) {
  198.     error("host error 33\n");
  199.     }
  200. }
  201. @
  202.  
  203.  
  204. 1.1
  205. log
  206. @Initial revision
  207. @
  208. text
  209. @d20 1
  210. a20 1
  211. static char rcsid[] = "$Header: string.c,v 1.1 88/04/25 13:09:17 ouster Exp $ SPRITE (Berkeley)";
  212. d118 1
  213. a118 1
  214.     entryPtr = Host_ByNetAddr(HOST_ETHER, (Address) etherAddr);
  215. d126 1
  216. a126 1
  217.     entryPtr = Host_ByNetAddr(HOST_ETHER, (Address) etherAddr);
  218. @
  219.